package com.sk.bilibili.view.activity;

import static com.sk.bilibili.utils.StringUtils.str;

import android.content.Context;
import android.content.Intent;

import com.bumptech.glide.Glide;
import com.sk.bilibili.bean.Member;
import com.sk.bilibili.bean.VideoSet;
import com.sk.bilibili.config.GlideApp;
import com.sk.bilibili.databinding.ActivityDynamicBinding;
import com.sk.bilibili.dto.DynamicInfo;
import com.sk.bilibili.model.activity.DynamicModel;

public class DynamicActivity extends BaseActivity<ActivityDynamicBinding, DynamicModel> {

    public static void start(Context context,Integer type, Integer targetId){
        Intent intent = new Intent(context, DynamicActivity.class);
        intent.putExtra("type",type);
        intent.putExtra("targetId",targetId);
        context.startActivity(intent);
    }

    private Integer type;
    private Integer targetId;

    @Override
    protected void afterSetView() {
        type= (Integer) getIntent().getSerializableExtra("type");
        targetId= (Integer) getIntent().getSerializableExtra("targetId");
        model.loadTarget(type,targetId);
        bindEvent();
    }

    private void bindEvent() {
        bind.ivBack.setOnClickListener(v->finish());
        bind.tvPub.setOnClickListener(v->model.pub(type,targetId,str(bind.etSend)));
    }

    public void loadTargetSuccess(DynamicInfo info) {
        bind.tvNikeName.setText(info.getName());
        bind.tvTitle.setText(info.getInfo());
        GlideApp.with(this).load(info.getCover()).img().into(bind.ivShow);
    }

    public void pubSuccess() {
        toast("分享成功");
        finish();
    }

}